<?php
/**
 * Created by PhpStorm.
 * User: yf
 * Date: 2018/5/24
 * Time: 下午3:56
 */

namespace App\Foundation\Traits;

use Hyperf\Utils\Context;

/**
 * 构建单例基类
 * Trait Singleton
 * @package App\Foundation\Traits
 */
trait ResultTrait
{

    //返回客户端数据
    public function returncode($code,$appId,$msg='success',$data=[]){//返回
        $this->result_code=$code;

        if($data){
            $secretVerify = $this->secretVerify();
            if($secretVerify){
                $data = $this->getEncryptData($data,$appId);
            }
            $res=['code'=>$code,'msg'=>$msg,'result'=>$data];

        }else{
            $res = $resultMsg = ['code'=>$code,'msg'=>$msg];
        }

        return $res;
    }

}